<?php

class module {
	
	var $zam;
	
	function main()
	{		
		switch ($this->zam->data['params'][1])
		{
			default:
			case 'profile':
				$this->myprofile();
				break;
			case 'user':
				$this->userprofile();
				break;
		}
	}
	
	#==================================
	# The current user's Profile
	#==================================
	function myprofile()
	{				
		$this->zam->skin->set_vars( array(
			'title'		=>	'My Profile',
			'head'		=>	$this->zam->tags->stylesheet('profile.css'),
			'subtemp'	=>	'profile.tpl',
			'user'		=>	$this->zam->sess->user
		) );
				
		$this->zam->skin->display('template.tpl');
	}
	
	#==================================
	# A user's profile
	#==================================
	function userprofile()
	{
		$where = sprintf("m.urlname = '%s' OR m.id = %d",
			$this->zam->data['params'][2],
			intval($this->zam->data['params'][2])
		);
		
		# Member data
		$result = $this->zam->sql->construct( array(
			'action'	=>	'select',
			'fields'	=>	'm.*, e.*',
			'db'		=>	constant('DB_MEMBERS') . ' m',
			'join'		=>	constant('DB_EXTRA') . ' e ON(m.id = e.member_id)',
			'where'		=>	$where,
			'limit'		=>	1
		) );
		
		$member = $this->zam->sql->fetch();
				
		$this->zam->skin->set_vars( array(
			'title'		=>	'My Profile',
			'subtemp'	=>	'profile.tpl',
			'user'		=>	$member
		) );
				
		$this->zam->skin->display('template.tpl');
	}
	
}

?>